package com.c5p1ng.distributed.lock.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = LockConfig.PREFIX)
public class LockConfig {
    public static final String PREFIX = "spring.lock";
    /**
     * 是否开启，默认开启
     */
    private boolean enable;
    /**
     * key前缀
     */
    private String keyPrefix = "";

    /**
     * redis地址
     */
    private String address;
    /**
     * 密码
     */
    private String password;
    /**
     * 数据库
     */
    private int database = 1;
    /**
     * 获取锁的超时时间，默认5000ms
     */
    private long acquireTimeout = 5000;
    /**
     * 锁的有效时间，默认5000ms
     */
    private long expireTime = 5000;
    private ClusterServer clusterServer;

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public String getKeyPrefix() {
        return keyPrefix;
    }

    public void setKeyPrefix(String keyPrefix) {
        this.keyPrefix = keyPrefix;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getDatabase() {
        return database;
    }

    public void setDatabase(int database) {
        this.database = database;
    }

    public long getAcquireTimeout() {
        return acquireTimeout;
    }

    public void setAcquireTimeout(long acquireTimeout) {
        this.acquireTimeout = acquireTimeout;
    }

    public long getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(long expireTime) {
        this.expireTime = expireTime;
    }

    public ClusterServer getClusterServer() {
        return clusterServer;
    }

    public void setClusterServer(ClusterServer clusterServer) {
        this.clusterServer = clusterServer;
    }

    public static class ClusterServer {

        private String[] nodeAddresses;

        public String[] getNodeAddresses() {
            return nodeAddresses;
        }

        public void setNodeAddresses(String[] nodeAddresses) {
            this.nodeAddresses = nodeAddresses;
        }
    }
}
